home *** CD-ROM | disk | FTP | other *** search
- *** 1.32 1992/08/14 17:24:38
- --- Changelog 1992/10/11 02:44:26
- ***************
- *** 342,344 ****
- --- 342,379 ----
- put out file symbols ala aln. julians nm should do better now.
-
- ----------------------------- Patchlevel 31 --------------------------------
- +
- + sym-ld.c:: michal
- + was`nt compiling anymore.
- +
- + ld.c, sym-ld.c:: michal
- + When searching through a library a function symdef_library was
- + repeatedly allocating and freeing (at the same address)
- + subentry->strings and subentry (line 2962) and later it was executing
- + free (subentry->strings);
- + subentry->strings = 0;
- + My NeXT was patient enough to survive such treatment for a few
- + iterations but after a while it was dropping a core from malloc().
- + Exactly the same applies to sym-ld. I do not know why this problem
- +
- + ld.c :: howard
- + Incorporate baserel patches.
- +
- + toglclr.c:: Frank Ridderbusch
- + rewrote toglclr for all flags: usage
- + toglclr [options] file file ...
- +
- + options: -fload = toggle `fast load'
- + -frun = toggle `load program into fast ram'
- + -fram = toggle `malloc from fast ram'
- +
- + toglclr.c:: ++jrb
- + clean it up for cross-environment, add support for
- + WORD_ALIGNED
- +
- + Makefile.cross, Makefile.st:: ++jrb
- + add target for toglclr
- +
- + cnm.c:: ++jrb
- + cleanup for hpux
- + ----------------------------- Patchlevel 32 --------------------------------
- *** 1.13 1992/06/03 18:40:27
- --- Makefile.cross 1992/10/11 02:44:26
- ***************
- *** 23,29 ****
- CFLAGS = -O -I. -I$(HOSTINC) -I$(CROSSINC) -DCROSSATARI=1 \
- -DCROSSDIR=\"$(CROSSDIR)\" -DCROSSLIB=\"$(CROSSLIB)\" -DWORD_ALIGNED=1
-
- ! ALL = ld sym-ld nm car size size68 tnm xstrip fixstk printstk
-
- all: $(ALL)
- #
- --- 23,29 ----
- CFLAGS = -O -I. -I$(HOSTINC) -I$(CROSSINC) -DCROSSATARI=1 \
- -DCROSSDIR=\"$(CROSSDIR)\" -DCROSSLIB=\"$(CROSSLIB)\" -DWORD_ALIGNED=1
-
- ! ALL = ld sym-ld nm car size size68 tnm xstrip fixstk printstk toglclr
-
- all: $(ALL)
- #
- ***************
- *** 74,79 ****
- --- 74,85 ----
- xstrip: strip.o
- $(CC) -o xstrip strip.o
-
- + #
- + # TOS format flags manipulator
- + #
- + toglclr: toglclr.o
- + $(CC) -o toglclr toglclr.o
- +
- install: $(ALL)
- cp ld $(CROSSLIB)/gcc-ld
- cp nm $(CROSSBIN)/cnm
- ***************
- *** 84,89 ****
- --- 90,96 ----
- cp xstrip $(CROSSBIN)/xstrip
- cp sym-ld $(CROSSBIN)/sym-ld
- cp fixstk printstk $(CROSSBIN)
- + cp toglclr $(CROSSBIN)
-
- clean:
- rm -f *.o
- *** 1.3 1992/06/03 18:40:27
- --- Makefile.hp 1992/10/11 02:44:26
- ***************
- *** 29,35 ****
-
- LIBS = $(ALLOCA) $(MALLOC1)
-
- ! ALL = ld sym-ld nm car size size68 tnm xstrip fixstk printstk
-
- all: $(ALL)
- #
- --- 29,35 ----
-
- LIBS = $(ALLOCA) $(MALLOC1)
-
- ! ALL = ld sym-ld nm car size size68 tnm xstrip fixstk printstk toglclr
-
- all: $(ALL)
- #
- ***************
- *** 80,85 ****
- --- 80,91 ----
- xstrip: strip.o
- $(CC) -o xstrip strip.o $(LIBS)
-
- + #
- + # TOS format flags manipulator
- + #
- + toglclr: toglclr.o
- + $(CC) -o toglclr toglclr.o
- +
- install: $(ALL)
- cp ld $(CROSSLIB)/gcc-ld
- cp nm $(CROSSBIN)/cnm
- ***************
- *** 89,95 ****
- cp tnm $(CROSSBIN)/tnm
- cp xstrip $(CROSSBIN)/xstrip
- cp sym-ld $(CROSSBIN)/sym-ld
- ! cp fixstk printstk $(CROSSBIN)
-
- clean:
- rm -f *.o
- --- 95,101 ----
- cp tnm $(CROSSBIN)/tnm
- cp xstrip $(CROSSBIN)/xstrip
- cp sym-ld $(CROSSBIN)/sym-ld
- ! cp fixstk printstk toglclr $(CROSSBIN)
-
- clean:
- rm -f *.o
- *** 1.12 1992/06/11 17:45:54
- --- Makefile.st 1992/10/11 02:44:26
- ***************
- *** 18,24 ****
- #ALL = gcc-ld.ttp sym-ld.ttp gcc-nm.ttp gcc-ar.ttp gcc-size.ttp size68.ttp
- # cnm.ttp fixstk.ttp printstk.ttp
- ALL = gcc-ld.ttp gcc-nm.ttp gcc-ar.ttp gcc-size.ttp size68.ttp \
- ! cnm.ttp fixstk.ttp printstk.ttp xstrip.ttp sym-ld.ttp
- all: $(ALL)
-
- #
- --- 18,24 ----
- #ALL = gcc-ld.ttp sym-ld.ttp gcc-nm.ttp gcc-ar.ttp gcc-size.ttp size68.ttp
- # cnm.ttp fixstk.ttp printstk.ttp
- ALL = gcc-ld.ttp gcc-nm.ttp gcc-ar.ttp gcc-size.ttp size68.ttp \
- ! cnm.ttp fixstk.ttp printstk.ttp xstrip.ttp sym-ld.ttp toglclr.ttp
- all: $(ALL)
-
- #
- ***************
- *** 81,86 ****
- --- 81,92 ----
- #
- xstrip.ttp: strip.c
- $(CC) -O -o xstrip.ttp strip.c -mshort -liio16
- +
- + #
- + # Manipulate TOS executable header flags
- + #
- + toglclr.ttp: toglclr.c
- + $(CC) -O -o toglclr.ttp toglclr.c -mshort -liio16
-
- clean:
- rm -f *.o core
- *** 1.1 1991/08/13 21:17:30
- --- Makefile.st.hp 1992/10/11 02:44:26
- ***************
- *** 12,24 ****
- # Cross GCC
- CC=$(CROSSBIN)/cgcc
-
- ! CFLAGS = -O -Datarist -I.
- LDFLAGS = -liio
-
- #ALL = gcc-ld.ttp sym-ld.ttp gcc-nm.ttp gcc-ar.ttp gcc-size.ttp size68.ttp
- # cnm.ttp fixstk.ttp printstk.ttp
- ALL = gcc-ld.ttp gcc-nm.ttp gcc-ar.ttp gcc-size.ttp size68.ttp \
- ! cnm.ttp fixstk.ttp printstk.ttp xstrip.ttp sym-ld.ttp
- all: $(ALL)
-
- #
- --- 12,24 ----
- # Cross GCC
- CC=$(CROSSBIN)/cgcc
-
- ! CFLAGS = -O2 -fstrength-reduce -fomit-frame-pointer -Datarist -I.
- LDFLAGS = -liio
-
- #ALL = gcc-ld.ttp sym-ld.ttp gcc-nm.ttp gcc-ar.ttp gcc-size.ttp size68.ttp
- # cnm.ttp fixstk.ttp printstk.ttp
- ALL = gcc-ld.ttp gcc-nm.ttp gcc-ar.ttp gcc-size.ttp size68.ttp \
- ! cnm.ttp fixstk.ttp printstk.ttp xstrip.ttp sym-ld.ttp toglclr.ttp
- all: $(ALL)
-
- #
- ***************
- *** 81,86 ****
- --- 81,92 ----
- #
- xstrip.ttp: strip.c
- $(CC) -O -o xstrip.ttp strip.c -mshort -liio16
- +
- + #
- + # Manipulate TOS executable header flags
- + #
- + toglclr.ttp: toglclr.c
- + $(CC) -O -o toglclr.ttp toglclr.c -mshort -liio16
-
- clean:
- rm -f *.o core
- *** 1.29 1992/08/14 17:24:38
- --- PatchLev.h 1992/10/11 02:44:27
- ***************
- *** 1,4 ****
- ! #define PatchLevel "31"
-
- /*
- * the Patch Level above is to identify the version
- --- 1,4 ----
- ! #define PatchLevel "32"
-
- /*
- * the Patch Level above is to identify the version
- *** 1.7 1992/08/14 17:24:38
- --- cnm.c 1992/10/11 02:44:27
- ***************
- *** 36,41 ****
- --- 36,47 ----
- #include <stdio.h>
- #include <st-out.h>
-
- + #if __STDC__
- + #include <stdlib.h>
- + #else
- + extern char *malloc(), *realloc();
- + #endif
- +
- #ifdef atarist
- # define READB "rb"
- #else
- ***************
- *** 42,48 ****
- # define READB "r"
- #endif
-
- ! #if !__STDC__
- typedef unsigned long size_t;
- #endif
-
- --- 48,54 ----
- # define READB "r"
- #endif
-
- ! #if !__STDC__ && !defined(hpux)
- typedef unsigned long size_t;
- #endif
-
- ***************
- *** 348,350 ****
- --- 354,380 ----
- fprintf(stderr, "cnm [-g] files...\n");
- exit(1);
- }
- +
- + #if !defined(__GNUC__) && defined(hpux)
- +
- + char *xmalloc(n)
- + int n; /* sigh! */
- + {
- + char *ret = (char *)malloc(n);
- +
- + if(ret) return ret;
- + perror("malloc");
- + exit(1);
- + }
- +
- + char *xrealloc(b, n)
- + char * b;
- + int n; /* sigh! */
- + {
- + char *ret = (char *)realloc(b, n);
- +
- + if(ret) return ret;
- + perror("realloc");
- + exit(2);
- + }
- + #endif
- *** 1.36 1992/08/14 17:24:38
- --- ld.c 1992/10/11 02:44:29
- ***************
- *** 396,401 ****
- --- 396,406 ----
- #define RELOC_TARGET_BITPOS(r) 0
- #define RELOC_TARGET_BITSIZE(r) 32
- #endif
- + #if defined(atarist) || defined(CROSSATARI)
- + #define RELOC_ADD_EXTRA(r) \
- + ((!RELOC_PCREL_P(r) && RELOC_TARGET_SIZE(r) < 2) \
- + ? BASE_OFFSET-text_size : 0)
- + #endif
-
- /* Special global symbol types understood by GNU LD. */
-
- ***************
- *** 1003,1009 ****
- void copy_text P_((struct file_entry *entry));
- void write_data P_((void));
- void copy_data P_((struct file_entry *entry));
- ! void perform_relocation P_((char *data, int pc_relocation, int data_size, struct relocation_info *reloc_info, int reloc_size, struct file_entry *entry));
- void write_rel P_((void));
- void flush_atari_rbuf P_((void));
- int reloc_less_p P_((struct relocation_info *reloc_1, struct relocation_info *reloc_2));
- --- 1008,1016 ----
- void copy_text P_((struct file_entry *entry));
- void write_data P_((void));
- void copy_data P_((struct file_entry *entry));
- ! void perform_relocation P_((char *data, int pc_relocation, int data_size,
- ! struct relocation_info *reloc_info, int reloc_size,
- ! struct file_entry *entry, int pure_text));
- void write_rel P_((void));
- void flush_atari_rbuf P_((void));
- int reloc_less_p P_((struct relocation_info *reloc_1, struct relocation_info *reloc_2));
- ***************
- *** 2715,2725 ****
- if (symdef_base[j].library_member_offset == offset)
- symdef_base[j].symbol_name_string_index = -1;
- }
- }
- -
- - /* We'll read the strings again if we need them again. */
- - free (subentry->strings);
- - subentry->strings = 0;
- }
- }
- }
- --- 2722,2731 ----
- if (symdef_base[j].library_member_offset == offset)
- symdef_base[j].symbol_name_string_index = -1;
- }
- + /* We'll read the strings again if we need them again. */
- + free (subentry->strings);
- + subentry->strings = 0;
- }
- }
- }
- }
- ***************
- *** 2977,2983 ****
- text segment. This is right for the type 0x601A Tos header
- and also for the standard Stminix header
- */
- ! data_start = text_start + text_size;
- #else
- if (! Tdata_flag_specified)
- data_start = N_DATADDR (outheader) + text_start - N_TXTADDR (outheader);
- --- 2983,2990 ----
- text segment. This is right for the type 0x601A Tos header
- and also for the standard Stminix header
- */
- ! if (! Tdata_flag_specified)
- ! data_start = text_start + text_size;
- #else
- if (! Tdata_flag_specified)
- data_start = N_DATADDR (outheader) + text_start - N_TXTADDR (outheader);
- ***************
- *** 3954,3959 ****
- --- 3961,3968 ----
- /* TOS */
- outheader.a_AZero1 = 0; /* good a place as any to do this */
- outheader.a_ldflgs = 0; /* fastload is NOT the default */
- + if (magic == NMAGIC)
- + outheader.a_ldflgs = F_SHTEXT; /* sharable text */
- outheader.a_isreloc = ISRELOCINFO; /* means reloc present (!) */
- #endif
- #endif
- ***************
- *** 4267,4273 ****
- /* Relocate the text according to the text relocation. */
-
- perform_relocation (bytes, entry->text_start_address, entry->header.a_text,
- ! reloc, entry->header.a_trsize, entry);
-
- /* Write the relocated text to the output file. */
-
- --- 4276,4282 ----
- /* Relocate the text according to the text relocation. */
-
- perform_relocation (bytes, entry->text_start_address, entry->header.a_text,
- ! reloc, entry->header.a_trsize, entry, (magic == NMAGIC));
-
- /* Write the relocated text to the output file. */
-
- ***************
- *** 4337,4347 ****
- fatal_with_file ("premature eof in data section of ", entry);
-
- perform_relocation (bytes, entry->data_start_address - entry->header.a_text,
- ! entry->header.a_data, reloc, entry->header.a_drsize, entry);
-
- mywrite (bytes, 1, entry->header.a_data, outdesc);
- }
-
- /* Relocate ENTRY's text or data section contents.
- DATA is the address of the contents, in core.
- DATA_SIZE is the length of the contents.
- --- 4346,4378 ----
- fatal_with_file ("premature eof in data section of ", entry);
-
- perform_relocation (bytes, entry->data_start_address - entry->header.a_text,
- ! entry->header.a_data, reloc, entry->header.a_drsize,
- ! entry, 0);
-
- mywrite (bytes, 1, entry->header.a_data, outdesc);
- }
-
- + static symbol *
- + retsym (p, entry)
- + struct relocation_info *p;
- + struct file_entry *entry;
- + {
- + register int symindex = RELOC_SYMBOL (p) * sizeof (struct nlist);
- + register symbol *sp = ((symbol *)
- + (((struct nlist *)
- + (((char *)entry->symbols) + symindex))
- + ->n_un.n_name));
- +
- + if (symindex >= entry->header.a_syms)
- + fatal_with_file ("relocation symbolnum out of range in ", entry);
- +
- + #ifdef N_INDR
- + /* Resolve indirection */
- + if ((sp->defined & ~N_EXT) == N_INDR)
- + sp = (symbol *) sp->value;
- + #endif
- + return sp;
- + }
- /* Relocate ENTRY's text or data section contents.
- DATA is the address of the contents, in core.
- DATA_SIZE is the length of the contents.
- ***************
- *** 4352,4358 ****
- /* This version is about to be severley hacked by Randy. Hope it
- works afterwards. */
- void
- ! perform_relocation (data, pc_relocation, data_size, reloc_info, reloc_size, entry)
- char *data;
- struct relocation_info *reloc_info;
- struct file_entry *entry;
- --- 4383,4390 ----
- /* This version is about to be severley hacked by Randy. Hope it
- works afterwards. */
- void
- ! perform_relocation (data, pc_relocation, data_size, reloc_info, reloc_size,
- ! entry, pure_text)
- char *data;
- struct relocation_info *reloc_info;
- struct file_entry *entry;
- ***************
- *** 4359,4364 ****
- --- 4391,4397 ----
- int pc_relocation;
- int data_size;
- int reloc_size;
- + int pure_text;
- {
- register struct relocation_info *p = reloc_info;
- struct relocation_info *end
- ***************
- *** 4373,4378 ****
- --- 4406,4412 ----
- register int relocation = 0;
- register int addr;
- register unsigned int mask = 0;
- + symbol *sp;
-
- #ifdef BYTE_SWAP /* swap relocation info */
- { /* BITFIELD ALERT BITFIELD ALERT */
- ***************
- *** 4395,4414 ****
-
- if (RELOC_EXTERN_P(p))
- {
- ! int symindex = RELOC_SYMBOL (p) * sizeof (struct nlist);
- ! symbol *sp = ((symbol *)
- ! (((struct nlist *)
- ! (((char *)entry->symbols) + symindex))
- ! ->n_un.n_name));
- !
- ! #ifdef N_INDR
- ! /* Resolve indirection */
- ! if ((sp->defined & ~N_EXT) == N_INDR)
- ! sp = (symbol *) sp->value;
- ! #endif
- !
- ! if (symindex >= entry->header.a_syms)
- ! fatal_with_file ("relocation symbolnum out of range in ", entry);
-
- /* If the symbol is undefined, leave it at zero. */
- if (! sp->defined)
- --- 4429,4435 ----
-
- if (RELOC_EXTERN_P(p))
- {
- ! sp = retsym(p, entry);
-
- /* If the symbol is undefined, leave it at zero. */
- if (! sp->defined)
- ***************
- *** 4475,4482 ****
- break;
-
- case 1:
- ! if (RELOC_MEMORY_ADD_P(p))
- ! relocation += mask & *(short *) (data + addr);
- *(short *) (data + addr) &= ~mask;
- *(short *) (data + addr) |= relocation;
- break;
- --- 4496,4513 ----
- break;
-
- case 1:
- ! if (RELOC_MEMORY_ADD_P(p)) {
- ! if (RELOC_PCREL_P(p))
- ! relocation += mask & *(short *) (data + addr);
- ! else
- ! relocation += mask & *(unsigned short *) (data + addr);
- ! }
- ! if (relocation > 32767 || relocation < -32768) {
- ! sp = retsym(p, entry);
- ! error ("relocation out of range for %s in %s",
- ! sp->name, entry->filename);
- ! make_executable = 0;
- ! }
- *(short *) (data + addr) &= ~mask;
- *(short *) (data + addr) |= relocation;
- break;
- ***************
- *** 4498,4503 ****
- --- 4529,4540 ----
-
- if (RELOC_MEMORY_ADD_P(p))
- relocation += mask & word;
- + if (pure_text && relocation > text_size+text_start) {
- + sp = retsym(p, entry);
- + error ("absolute reference to %s from pure-text in %s",
- + sp->name, entry->filename);
- + make_executable = 0; /* set exit code */
- + }
- word &= ~mask;
- word |= relocation;
- data[addr] = word >> 24;
- ***************
- *** 4671,4677 ****
- qsort(entry->textrel, n_relocs, sizeof (struct relocation_info),
- reloc_less_p);
- for (reloc_num = n_relocs - 1 ; reloc_num >= 0 ; reloc_num-- )
- ! if (!emit_atari_reloc(entry->textrel[reloc_num].r_address + text_base))
- fprintf(stderr, " while processing text rel %d/%d of entry %s\n",
- reloc_num, n_relocs, entry->filename);
- }
- --- 4708,4715 ----
- qsort(entry->textrel, n_relocs, sizeof (struct relocation_info),
- reloc_less_p);
- for (reloc_num = n_relocs - 1 ; reloc_num >= 0 ; reloc_num-- )
- ! if ((entry->textrel[reloc_num].r_length == 2) &&
- ! !emit_atari_reloc(entry->textrel[reloc_num].r_address + text_base))
- fprintf(stderr, " while processing text rel %d/%d of entry %s\n",
- reloc_num, n_relocs, entry->filename);
- }
- *** 1.21 1992/07/30 20:53:34
- --- sym-ld.c 1992/10/11 02:44:31
- ***************
- *** 892,898 ****
- --- 892,902 ----
-
- int xmalloc ();
- int xrealloc ();
- + #if __STDC__
- + void fatal (char *string, ...);
- + #else
- void fatal ();
- + #endif
- void fatal_with_file ();
- void perror_name ();
- void perror_file ();
- ***************
- *** 2435,2445 ****
- if (symdef_base[j].library_member_offset == offset)
- symdef_base[j].symbol_name_string_index = -1;
- }
- }
- -
- - /* We'll read the strings again if we need them again. */
- - free (subentry->strings);
- - subentry->strings = 0;
- }
- }
- }
- --- 2439,2448 ----
- if (symdef_base[j].library_member_offset == offset)
- symdef_base[j].symbol_name_string_index = -1;
- }
- + /* We'll read the strings again if we need them again. */
- + free (subentry->strings);
- + subentry->strings = 0;
- }
- }
- }
- }
- ***************
- *** 4913,4919 ****
-
- int
- parse (arg, format, error)
- ! char *arg, *format;
- {
- int x;
- if (1 != sscanf (arg, format, &x))
- --- 4916,4922 ----
-
- int
- parse (arg, format, error)
- ! char *arg, *format, *error;
- {
- int x;
- if (1 != sscanf (arg, format, &x))
- *** 1.2 1992/07/21 14:52:06
- --- toglclr.c 1992/10/11 02:44:31
- ***************
- *** 1,9 ****
- ! /*
- ! * utility to toggle clear TPA beyond BSS flag in .prg header for Tos 1.4
- *
- ! * Usage: toglclr file file ....
- *
- ! * ++jrb
- */
-
- #include <stdio.h>
- --- 1,26 ----
- ! /* -*- Mode: Elec-C -*-
- ! * toglclr.c -- utility to toggle the program load flags in the .prg header.
- *
- ! * usage: toglclr [options] file file ...
- ! *
- ! * Author : J.R. Bammi, modified by F. Ridderbusch
- ! * Created On : Some time ago.
- ! * Last Modified By: J.R. Bammi
- ! * Last Modified On: Fri Sep 25 12:00:28 1992
- ! * Update Count : 6
- ! * Status : Unknown, Use with caution!
- ! */
- !
- ! /* HISTORY
- ! * 25-Sep-1992 ++jrb
- ! * Added support for cross-environment with support for
- ! * WORD_ALIGNED hosts.
- *
- ! * 13-Sep-1992 Frank Ridderbusch
- ! * This program was originally written by J.R. Bammi
- ! * (bammi@cadence.com) to toggle the clear TPA above BSS flag
- ! * introduced with TOS 1.4. I extended it to also handle the additional
- ! * program flags introduced with the TOS versions for the STE and TT.
- */
-
- #include <stdio.h>
- ***************
- *** 13,21 ****
- #include <st-out.h>
-
- #ifndef FILENAME_MAX
- ! # define FILENAME_MAX 128
- #endif
-
- int toggle (fd, fn)
- int fd;
- char *fn;
- --- 30,111 ----
- #include <st-out.h>
-
- #ifndef FILENAME_MAX
- ! #define FILENAME_MAX 1024
- #endif
-
- + int flags_to_toggle = 0;
- +
- + #ifdef WORD_ALIGNED
- +
- + #define ckread(addr, bytes, fd) if(read(fd, addr, bytes) != bytes) return 1;
- + #define ckwrite(addr, bytes, fd) if(write(fd, addr, bytes) != bytes) return 1;
- +
- + int readhead(h, fd)
- + struct aexec *h;
- + int fd;
- + {
- + short i;
- + long j;
- + int k;
- +
- + ckread(&i, 2, fd);
- + h->a_magic = i;
- + ckread(&j, 4, fd);
- + h->a_text = j;
- + ckread(&j, 4, fd);
- + h->a_data = j;
- + ckread(&j, 4, fd);
- + h->a_bss = j;
- + ckread(&j, 4, fd);
- + h->a_syms = j;
- + ckread(&j, 4, fd);
- + h->a_AZero1 = j;
- + ckread(&j, 4, fd);
- + h->a_ldflgs = j;
- + ckread(&i, 2, fd);
- + h->a_isreloc = i;
- +
- + return 0;
- + }
- +
- + int writehead(h, fd)
- + struct aexec *h;
- + int fd;
- + {
- + short i;
- + long j;
- + int k;
- +
- + i = h->a_magic;
- + ckwrite(&i, 2, fd);
- + j = h->a_text;
- + ckwrite(&j, 4, fd);
- + j = h->a_data;
- + ckwrite(&j, 4, fd);
- + j = h->a_bss;
- + ckwrite(&j, 4, fd);
- + j = h->a_syms;
- + ckwrite(&j, 4, fd);
- + j = h->a_AZero1;
- + ckwrite(&j, 4, fd);
- + j = h->a_ldflgs;
- + ckwrite(&j, 4, fd);
- + i = h->a_isreloc;
- + ckwrite(&i, 2, fd);
- +
- + return 0;
- + }
- +
- + #else
- +
- + #define readhead(addr, fd) \
- + (read(fd, addr, sizeof(struct aexec)) != sizeof(struct aexec))
- +
- + #define writehead(addr, fd) \
- + (write(fd, addr, sizeof(struct aexec)) != sizeof(struct aexec))
- +
- + #endif /* WORD_ALIGNED */
- +
- int toggle (fd, fn)
- int fd;
- char *fn;
- ***************
- *** 22,29 ****
- {
- struct aexec head;
- unsigned long t;
-
- ! if(read(fd, &head, sizeof(head)) != sizeof(head))
- {
- perror(fn);
- return 4;
- --- 112,120 ----
- {
- struct aexec head;
- unsigned long t;
- + char *ptr;
-
- ! if(readhead(&head, fd))
- {
- perror(fn);
- return 4;
- ***************
- *** 35,49 ****
- }
-
- t = head.a_AZero2;
- ! head.a_AZero2 ^= 1;
- ! lseek(fd, 0L, SEEK_SET);
- ! if(write(fd, &head, sizeof(head)) != sizeof(head))
- {
- ! perror(fn);
- ! return 16;
- }
-
- ! printf("%s: was %d is %d\n", fn, (int)t, (int)head.a_AZero2);
- return 0;
- }
-
- --- 126,154 ----
- }
-
- t = head.a_AZero2;
- ! if (flags_to_toggle)
- {
- ! head.a_AZero2 ^= flags_to_toggle;
- ! lseek(fd, 0L, SEEK_SET);
- ! if(writehead(&head, fd))
- ! {
- ! perror(fn);
- ! return 16;
- ! }
- }
-
- ! printf("%s: `fast load' bit was %d is now %d\n", fn,
- ! (int)((t & F_FASTLOAD) == F_FASTLOAD),
- ! (int)((head.a_AZero2 & F_FASTLOAD) == F_FASTLOAD));
- !
- ! printf("%s: `run in fast ram' bit was %d is now %d\n", fn,
- ! (int)((t & F_ALTLOAD) == F_ALTLOAD),
- ! (int)((head.a_AZero2 & F_ALTLOAD) == F_ALTLOAD));
- !
- ! printf("%s: `malloc from fast ram' bit was %d is now %d\n", fn,
- ! (int)((t & F_ALTALLOC) == F_ALTALLOC),
- ! (int)((head.a_AZero2 & F_ALTALLOC) == F_ALTALLOC));
- !
- return 0;
- }
-
- ***************
- *** 57,69 ****
-
- if(argc < 2)
- {
- ! fprintf(stderr, "usage: toglclr file file .....\n");
- exit(1);
- }
-
- while(--argc > 0)
- {
- ! (void) strcpy(fn, *++argv);
- if((fd = open(fn, 2)) < 0)
- {
- perror(fn);
- --- 162,189 ----
-
- if(argc < 2)
- {
- ! fprintf(stderr, "usage: toglclr [options] file file .....\n\n");
- ! fprintf(stderr, "options: -fload = toggle `fast load' bit\n");
- ! fprintf(stderr, " -frun = toggle `load program into fast ram' bit\n");
- ! fprintf(stderr, " -fram = toggle `malloc from fast ram' bit\n\n");
- ! fprintf(stderr, "without options the current state is reported.\n");
- exit(1);
- }
-
- + while (**++argv == '-')
- + {
- + if (!strcmp(*argv, "-fload"))
- + flags_to_toggle |= F_FASTLOAD;
- + if (!strcmp(*argv, "-frun"))
- + flags_to_toggle |= F_ALTLOAD;
- + if (!strcmp(*argv, "-fram"))
- + flags_to_toggle |= F_ALTALLOC;
- + --argc;
- + }
- +
- while(--argc > 0)
- {
- ! (void) strcpy(fn, *argv++);
- if((fd = open(fn, 2)) < 0)
- {
- perror(fn);
- ***************
- *** 79,82 ****
-
- return status;
- }
- -
- --- 199,201 ----
-